package com.treasure.mall.zbqmallapi.vo.order;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.treasure.mall.biz.entity.embeddable.ReceivingInfo;
import com.treasure.mall.zbq.common.ienum.order.OrderEnums;
import lombok.Data;

import javax.persistence.Column;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.zbqmallapi.vo.order
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/6/15 22:25
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 * Copyright 2019-2022 com.treasure.mall.zbqmallapi.vo.order Inc. All rights reserved.
 */
@Data
public class SubOrderVO extends BaseOrderVO {

    /**
     * 去支付时，使用该编号
     */
    private String dealOrderId;

    /**
     * 收货信息
     */
    private ReceivingInfo receivingInfo;

    /**
     * 商家退货地址
     */
    private ReceivingInfo returnedPurchase;

    /**
     * 订单状态
     */
    private OrderEnums.Status status;
    /**
     * 商品数量
     */
    private int goodsNum;
    /**
     * 最终金额
     */
    private BigDecimal finalAmount;
    /**
     * 剩余支付金额
     */
    private BigDecimal surplusAmount;
    /**
     * 商品金额
     */
    private BigDecimal goodsAmount;
    /**
     * 运费
     */
    private BigDecimal freightAmount;
    /**
     * 优惠金额
     */
    private BigDecimal pmtAmount;
    /**
     * 鉴定服务费
     */
    private BigDecimal identifyFee;
    /**
     * 抵扣的余额
     */
    private BigDecimal balance;
    /**
     * 支付超时时间
     */
    protected LocalDateTime payExpireTime;
    /**
     * 支付时间
     */
    protected LocalDateTime payTime;
    /**
     * 支付状态
     */
    protected OrderEnums.PayStatus payStatus;
    /**
     * 订单类型
     */
    private OrderEnums.OrderType orderType;

    /**
     * 用户留言
     */
    private String memo;
    /**
     * 订单备注
     */
    private String remark;
    /**
     * 签收时间
     */
    private LocalDateTime lastReceivedTime;


    /**
     * 订单项
     */
    private List<OrderItemVO> orderItem;


    /**
     * 付款单号
     */
    @JsonIgnore
    private String paymentBillId;

    /**
     * 第三方单号
     */
    private String thirdTradingNo;


    public boolean isReceived() {
        return orderItem.stream().allMatch(p -> p.getDeliverStatus() == OrderEnums.DeliverStatus.RECEIVED);
    }

    /**
     * 退款金额
     */
    private BigDecimal refundAmount;
    /**
     * 用户订单状态
     */
    private OrderEnums.UserOrderStatus userOrderStatus;


}
